package service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import dao.TestJavaMapper;
import domain.TestJava;
import domain.TestJavaExample;

/**
 * User: xinxin
 * Date: 2016-11-05
 * Time: 21:31
 * FIXME
 */
@Service
public class TestJavaServiceImp implements TestJavaServiceI {
    @Autowired
    TestJavaMapper mTestJavaMapper;
    @Override
    public boolean addTestResult(TestJava testJava) {
        return mTestJavaMapper.insert(testJava)>0;
    }

    @Override
    public List<TestJava> getTestResultByStudentId(int studentId) {
        TestJavaExample testJavaExample = new TestJavaExample();
        TestJavaExample.Criteria criteria = testJavaExample.createCriteria();
        criteria.andStudentIdEqualTo(studentId);
        testJavaExample.or(criteria);
        List<TestJava> testJavas = mTestJavaMapper.selectByExample(testJavaExample);
        if (testJavas != null) {
            return testJavas;
        }
        return null;
    }
}
